<% flash.each do |key, value| %>
  <div id="t-flash" class="ui <%= key %> message flash center aligned segment">
  	  <%= value %>
  </div>
<% end %>
<script>
  $(function(){
    setTimeout(function(){
      $(".ui.flash").closest(".message").addClass('animated fadeOutUp')
                                                        .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', 
      function(){
        $('#t-flash').remove();
      });
    },3000)
  })
</script>